//
//  FPPostListTableViewCell.m
//  ForestPack
//
//  Created by jimmy on 2018/7/6.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "FPPostListTableViewCell.h"
#import "UIView+Utils.h"

@interface FPPostListTableViewCell()

@property (nonatomic,strong)  UILabel  * titleLabel;
@property (nonatomic,strong)  UILabel  * timeLabel;
//@property (nonatomic,strong)  UILabel  * titleLabel;

@end

@implementation FPPostListTableViewCell

+ (FPPostListTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"FPPostListTableViewCell";
    FPPostListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[FPPostListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

-(void)setPostListDataModel:(PostListDataModel *)postListDataModel
{
    _postListDataModel = postListDataModel;
    
    self.titleLabel.text = postListDataModel.title;
    self.timeLabel.text = postListDataModel.time;
}

- (void)createSubView
{
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 11, SCREEN_WIDTH/2, 20)];
//    self.titleLabel.text = @"森林头条找专业的人";
    self.titleLabel.textColor = FONTCOLOR_BLACK;
    self.titleLabel.font = Kfont(14);
    [self addSubview:self.titleLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.right, 11, SCREEN_WIDTH-self.titleLabel.width - 20, 20)];
//    self.timeLabel.text = @"2018.02.25 12:45:23";
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.textColor = RGB_COLOR(153,153,153);
    self.timeLabel.font = Kfont(12);
    [self addSubview:self.timeLabel];
    
}

@end


@interface FPPostDetailTableViewCell()

@property (nonatomic,strong)  UILabel     * titleLabel;
@property (nonatomic,strong)  UILabel     * timeLabel;
@property (nonatomic,strong)  UIImageView * contenImageV;
@property (nonatomic,strong)  UITextView  * detailTextView;

@end

@implementation FPPostDetailTableViewCell

+ (FPPostDetailTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"FPPostDetailTableViewCell";
    FPPostDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[FPPostDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

-(void)setPostDetailModel:(FPPostDetailModel *)postDetailModel
{
    _postDetailModel = postDetailModel;
    
    self.titleLabel.text = postDetailModel.title;
    self.timeLabel.text = postDetailModel.time;
    self.detailTextView.text = postDetailModel.content;
    
}

- (void)createSubView
{
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(15), ScreenX375(10), SCREEN_WIDTH/2 + ScreenX375(20), ScreenX375(18))];
    self.titleLabel.text = @"森林头条找专业的人";
    self.titleLabel.textColor = FONTCOLOR_BLACK;
    self.titleLabel.font = Kfont(14);
    [self addSubview:self.titleLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(15), self.titleLabel.bottom + ScreenX375(5), self.titleLabel.width, ScreenX375(15))];
    self.timeLabel.text = @"2018.02.25 12:45:23";
    self.timeLabel.textColor = RGB_COLOR(153,153,153);
    self.timeLabel.font = Kfont(12);
    [self addSubview:self.timeLabel];
    
    //在这里下载网络图片
    //  [mainImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:hostUrlsImg,imageDict[@"img"]]] placeholderImage:[UIImage imageNamed:@""]];
    
    self.contenImageV = [[UIImageView alloc] init];
    self.contenImageV.frame = CGRectMake(ScreenX375(15), self.timeLabel.bottom + ScreenX375(10), SCREEN_WIDTH - ScreenX375(30), ScreenX375(190));
    self.contenImageV.image = [UIImage imageNamed:@"头部背景"];
    [self addSubview:self.contenImageV];
    
    self.detailTextView = [[UITextView alloc] initWithFrame:CGRectMake(ScreenX375(15), self.contenImageV.bottom + ScreenX375(10), SCREEN_WIDTH - ScreenX375(30), SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - TAB_BAR_HEIGHT)];
    self.detailTextView.text = @"一体成型盒-盒盖前面外插_安全扣_带卡扣_微坑，由于受运输限制我们只接受江浙沪地区的订单。在您完成下单后我们的...";
    self.detailTextView.textColor = RGB_COLOR(153,153,153);
    self.detailTextView.font = Kfont(12);
    [self addSubview:self.detailTextView];
    
}

@end


